<#--
  Frontend API 标准方法
-->
<#assign lowerEntity = table.entityName?uncap_first>

  /**
   * 分页查询${table.comment!table.entityName}
   */
  list${table.entityName}: async (params: any): Promise<ApiResponse<PageResponse<any>>> => {
    return request.get(`${'$'}{base}`, { params })
  },

  /**
   * 查询${table.comment!table.entityName}详情
   */
  get${table.entityName}: async (id: string | number): Promise<ApiResponse<any>> => {
    return request.get(`${'$'}{base}/${'$'}{id}`)
  },

  /**
   * 创建${table.comment!table.entityName}
   */
  create${table.entityName}: async (data: any): Promise<ApiResponse<any>> => {
    return request.post(base, data)
  },

  /**
   * 更新${table.comment!table.entityName}
   */
  update${table.entityName}: async (id: string | number, data: any): Promise<ApiResponse<any>> => {
    return request.put(`${'$'}{base}/${'$'}{id}`, data)
  },

  /**
   * 删除${table.comment!table.entityName}
   */
  delete${table.entityName}: async (id: string | number): Promise<ApiResponse<void>> => {
    return request.delete(`${'$'}{base}/${'$'}{id}`)
  },

  /**
   * 批量删除${table.comment!table.entityName}
   */
  batchDelete${table.entityName}: async (ids: (string | number)[]): Promise<ApiResponse<void>> => {
    return request.delete(`${'$'}{base}/batch`, { data: ids })
  },

  /**
   * 导出${table.comment!table.entityName}
   */
  export${table.entityName}: async (params: any): Promise<void> => {
    return request.download({
      url: `${'$'}{base}/export`,
      method: 'post',
      data: params,
      filename: `${table.comment!table.entityName}列表_${'$'}{new Date().toISOString().slice(0, 10)}.xlsx`
    })
  },

  /**
   * 导入${table.comment!table.entityName}
   */
  import${table.entityName}: async (file: File, updateSupport: boolean = false): Promise<ApiResponse<any>> => {
    const formData = new FormData()
    formData.append('file', file)
    formData.append('updateSupport', String(updateSupport))
    return request.upload({
      url: `${'$'}{base}/import`,
      data: formData
    })
  },

  /**
   * 下载${table.comment!table.entityName}导入模板
   */
  download${table.entityName}Template: async (): Promise<void> => {
    return request.download({
      url: `${'$'}{base}/template`,
      filename: `${table.comment!table.entityName}导入模板.xlsx`
    })
  }

